package cn.wolfcode.crm.web.interceptor;

import cn.wolfcode.crm.domain.Employee;
import cn.wolfcode.crm.util.UserContext;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 登录拦截器
 */
/*public class LoginInterceptor implements HandlerInterceptor {

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        //从Session中获取 当前员工对象
        Employee employee = UserContext.getCurrentUser();
        System.out.println(handler);
        HandlerMethod handlerMethod = (HandlerMethod) handler;
        System.out.println(handlerMethod);

        //若不存在 返回登录页面 不放行
        if (employee == null) {
            response.sendRedirect("/login.html");
            return false;
        }
        return true;
    }
}*/
